package xcmg.device.web.order;

import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import xcmg.device.infra.BasicController;
import xcmg.device.service.order.GpsMmSwOrderService;
import xcmg.device.service.vo.order.GpsMmSwOrderVO;
import yb.ecp.fast.infra.annotation.FastMappingInfo;
import yb.ecp.fast.infra.infra.ActionResult;
import yb.ecp.fast.infra.infra.PageCommonVO;
import yb.ecp.fast.infra.infra.SearchCommonVO;


/**
 * GpsMmSwOrder Controller 实现类
 */
@RestController
@RequestMapping("/gpsMmSwOrder")
@Api(tags = "GPS订单")
@Slf4j
public class GpsMmSwOrderController extends BasicController {
    @Autowired
    private GpsMmSwOrderService gpsMmSwOrderService;

    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @FastMappingInfo(needLogin = true)
    public ActionResult<PageInfo<GpsMmSwOrderVO>> list(@RequestBody SearchCommonVO<GpsMmSwOrderVO> condition) throws Exception {
        GpsMmSwOrderVO gpsMmSwOrderVO = condition.getFilters();
        if (gpsMmSwOrderVO == null) {
            gpsMmSwOrderVO = new GpsMmSwOrderVO();
        }
        if (gpsMmSwOrderVO.getOrgId() == null) {
            gpsMmSwOrderVO.setOrgId(getOrgId());
        }
        condition.setFilters(gpsMmSwOrderVO);
        PageCommonVO<GpsMmSwOrderVO> pageCommonVO = gpsMmSwOrderService.list(condition);
        return actionValueResult(pageCommonVO.getPageInfo());
    }

    @RequestMapping(value = "/page", method = RequestMethod.POST)
    @FastMappingInfo(needLogin = true)
    public ActionResult<PageInfo<GpsMmSwOrderVO>> page(@RequestBody SearchCommonVO<GpsMmSwOrderVO> condition) throws Exception {
        GpsMmSwOrderVO gpsMmSwOrderVO = condition.getFilters();
        if (gpsMmSwOrderVO == null) {
            gpsMmSwOrderVO = new GpsMmSwOrderVO();
        }
        if (gpsMmSwOrderVO.getDownOrgId() == null) {
            gpsMmSwOrderVO.setDownOrgId(getOrgId());
        }
        condition.setFilters(gpsMmSwOrderVO);
        PageCommonVO<GpsMmSwOrderVO> pageCommonVO = gpsMmSwOrderService.list(condition);
        return actionValueResult(pageCommonVO.getPageInfo());
    }

    @RequestMapping(value = "/item", method = RequestMethod.GET)
    @FastMappingInfo(needLogin = true)
    public ActionResult<GpsMmSwOrderVO> item(Long id) {
        return actionValueResult(gpsMmSwOrderService.getById(id));
    }
}
